﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BUS
{
    public class KhuyenMaiBus
    {
        public static bool ThemKhuyenMai(DTO.KhuyenMaiDto km)
        {
            return DAO.KhuyenMaiDao.ThemKhuyenMai(km);
        }
        public static bool XoaKhuyenMai(int id)
        {
            return DAO.KhuyenMaiDao.XoaKhuyenMai(id);
        }
        public static List<DTO.KhuyenMaiDto> LayDanhSachKhuyenMai()
        {
            return DAO.KhuyenMaiDao.LayDanhSachKhuyenMai();
        }
        public static DTO.KhuyenMaiDto LayKhuyenMaiTheoID(int id)
        {
            return DAO.KhuyenMaiDao.LayKhuyenMaiTheoID(id);
        }

        public static int LayTiLeKhuyenMaiTheoID(int id)
        {
            DTO.KhuyenMaiDto KhuyenMai = DAO.KhuyenMaiDao.LayKhuyenMaiTheoID(id);
            DateTime currentDate = DateTime.Now;
            if (currentDate >= KhuyenMai.NgayBatDau && currentDate <= KhuyenMai.NgayKetThuc)
                return KhuyenMai.HinhThuc;
            return 0;
        }
    }
}
